package cn.com.kh;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.*;
import java.util.Scanner;

/**
 * @projectName: ngsapitask-ms
 * @package: cn.com.kh
 * @className: Dev
 * @author: LiJT
 * @description: TODO
 * @date: 2022-08-08 13:02
 * @version: 1.0
 */
public class DevOld {
    private static final Log log = LogFactory.getLog(DevOld.class);

    public static void main(String[] args) throws Exception {

        System.out.println("开始读取:" + System.currentTimeMillis());
        // 创建文件对象
        File file = new File("C:\\Users\\LiJT\\Desktop\\待归档\\民生加银基金对账单Demo.html");

        // 创建FileReader对象
        FileReader fileReader = new FileReader(file);

        // 创建BufferedReader对象
        BufferedReader bufferedReader = new BufferedReader(fileReader);

        // 读取文件内容并打印
        String line1 = null;
        StringBuilder content1 = new StringBuilder();
        while ((line1 = bufferedReader.readLine()) != null) {

            content1.append(System.lineSeparator() + line1);
        }

        System.out.println("读取完成:" + System.currentTimeMillis());
        String content = content1.toString();
        System.out.println("开始替换:" + System.currentTimeMillis());

        long startTime = System.currentTimeMillis();
        //String contentTemp = null;
        String contentTemp = content.replace("http://www.msjyfund.com.cn/data/kefu/seal_smal2l.png", "http://www.msjyfund.com.cn/data/kefu/seal3.png");
        System.out.println("替换完成1:" + (System.currentTimeMillis() - startTime));

        startTime = System.currentTimeMillis();
        //contentTemp = StringUtils.replace(content, "http://www.msjyfund.com.cn/data/kefu/seal_small.png", "http://www.msjyfund.com.cn/data/kefu/seal.png");
        System.out.println("替换完成2:" + (System.currentTimeMillis() - startTime));

        boolean bool = KHUtil.writeFile(contentTemp, "C:\\Users\\LiJT\\Desktop\\民生加银基金对账单OLD_" + System.currentTimeMillis() + ".html");
        log.debug("将邮件正文写到本地 是否写入成功：" + bool);

    }
}
